<?php
/**
* wakevents global event handler service
*/
class wakEvents_handler extends wakService {

	/**
	* executes an event
	* searches for type specific handler
	* @param string $call
	* @param 
	* @return mixed event return value
	*/
	public function run($call,$parameters=null) {
		$call=new wakevents_eventcall($call); //print_r($call);
		$type=$call->get('type'); //echo $type;
		// searching for type specific handler
		$handler=$this->_getTypeHandler($type);
		return $handler->run($call,$parameters);
	}/**/
	
	/**
	* return handler service instance for given event type
	* @access private
	* @param string $type
	* @return wakService
	*/
	private function & _getTypeHandler($type) {
		$handler=$this->pkg->getService($type);
		return $handler;
	}/**/
}
?>
